﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<CRM.Models.TrainingsTrainers>>" %>
<%@ Import Namespace="CRM.Models" %>
<%@ Import Namespace="CRM.Resourses" %>

<% Html.DevExpress().GridView(settings =>
                                    {
                                        settings.Name = "gdTrainingsTrainers";
                                        settings.KeyFieldName = "IdTrainingsTrainer";
                                        settings.CallbackRouteValues =
                                            new { Controller = "Dictionaries", Action = "TrainingsTrainersPartial" };
                                        settings.SettingsPager.PageSize = 20;
                                       
                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.Name;
                                            column.FieldName = "Name";
                                        });

                                        //
                                        //Добавление комбобоксов
                                        //
                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "IdTrainingsCenter";
                                            column.Caption = Resourses.TrainingsCenters;
                                            column.ColumnType = MVCxGridViewColumnType.ComboBox;

                                            var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                            if (comboBoxProperties != null)
                                            {
                                               
                                                comboBoxProperties.DataSource =
                                                    DB.TrainingsCenters;

                                                comboBoxProperties.TextField = "NameRu";
                                                comboBoxProperties.ValueField = "IdTrainingsCenter";
                                                comboBoxProperties.ValueType = typeof(int);
                                            }
                                        });
                                        //конец комбобокса
                                        
                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.Phone;
                                            column.FieldName = "Phone";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.Email;
                                            column.FieldName = "Email";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.CommentsRu;
                                            column.FieldName = "CommentsRu";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.CommentsEn;
                                            column.FieldName = "CommentsEn";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.IsActive;
                                            column.FieldName = "IsActive";
                                            column.ColumnType = MVCxGridViewColumnType.CheckBox;
                                        });

                                        //
                                        //Добавление редактирования
                                        //
                                        settings.CommandColumn.Visible = true;
                                        settings.CommandColumn.NewButton.Visible = true;
                                        settings.CommandColumn.DeleteButton.Visible = true;
                                        settings.CommandColumn.EditButton.Visible = true;
                                        settings.SettingsBehavior.ConfirmDelete = true;
                                        settings.Settings.ShowFilterRow = true;
                                        settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "Dictionaries", Action = "TrainingsTrainersPartialUpdate" };
                                        settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "Dictionaries", Action = "TrainingsTrainersPartialAdd" };
                                        settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "Dictionaries", Action = "TrainingsTrainersPartialDelete" };

                                        settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
                                        settings.Width = Unit.Percentage(100);

                                        
                                    })
       .Bind(Model).GetHtml();
%>

